#ifndef GRAMMARSYMBOL_H
#define GRAMMARSYMBOL_H
#include<assert.h>
#include<fstream>
#include<sstream>
#include<iostream>
#include"Config.h"
#include<math.h>
class GrammarSymbol{
  double *emission,*binary;
  double e_type,b_type;
  int Token_Num,Grammar_Num;
  int e_len,b_len;
  double e_change,b_change,t_change;
  int id;
  
  friend std::istream& operator>>(std::istream&,GrammarSymbol&);
  friend std::ostream& operator<<(std::ostream&,GrammarSymbol&);
  public:
  GrammarSymbol();
  ~GrammarSymbol();
  double getemission(int t_id);
  double getbinary(int l_id,int r_id);
  int twoD2oneD(int l_id,int r_id);
  void setemission(int t_id,double v);
  void setbinary(int l_id,int r_id,double v);
  void reademission(std::string line);
  void readbinary(std::string line);
 
  void initialize(int g_id,int g_num,int t_num);
  void settype_e(double v);
  void settype_b(double v);
  void setg_num(int g_num);
  void sett_num(int t_num);
  void set_id(int g_id);
  void resetchanges();
  double last_change();
};
double readtyperule(std::string line);
std::istream& operator>>(std::istream& in,GrammarSymbol& s);
std::ostream& operator<<(std::ostream& out,GrammarSymbol& s);

#endif
